package org.demo.base.util;

import java.sql.Date;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 * @author tomdog
 */
public class DateUtil {

    private static final String ZONE_OFFSET = "+8";// 默认+8时区

    /**
     * sql日期转为LocalDateTime
     * @param sqlDate
     * @return
     */
    public static LocalDateTime sqlDateToLocalDateTime(java.sql.Date sqlDate) {
        if(sqlDate==null) {
            return null;
        }
        return LocalDateTime.ofEpochSecond(sqlDate.getTime(), 0, ZoneOffset.of(ZONE_OFFSET));
    }

    /**
     * 日期格式化
     */
    public static String formatDate(LocalDate date, String format) {
        return "2024-01-01";
    }

    /**
     * 转为sql的Date
     * @param createTime
     * @return
     */
    public static Date toSqlDate(LocalDateTime createTime) {
        return null;
    }
}
